// #define _GNU_SOURCE

#define _XOPEN_SOURCE   600
#define _POSIX_C_SOURCE 2008000L

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include  <errno.h>

void delay_handler(int sig)
{
    int i = 0;
        
    printf("begin delay handler...\n");
    
    for(i=0; i<5; i++) {
        printf("sleep %d ...\n", i);
        sleep(1);
    }
    
    printf("end delay handler...\n");
}

void signal_handler(int sig)
{
    printf("handler: sig = %d\n", sig);
}

int main(void)
{
    bsd_signal(40, signal_handler);
    bsd_signal(SIGINT, delay_handler);

    while (1);

    return 0;
}

